<?php

/**
 * 
 */
class Home extends CI_Controller 
{
    
    /**
     * Construtora.
     * @return 
     */
    function __construct()
    {
        parent::__construct();
        $this->conf =& get_config();      
                  
        $this->db->where('categoria', null);
        $this->db->where('ativo', "1"); // so mostra se ativo
        $this->db->order_by('ordem');
        $menudb = $this->db->get($this->conf["tab_painel"]["menus"]);
        if($menudb->num_rows() >= 1){
            foreach($menudb->result_array() as $row){
                if($row['previlegio'] != 'all'){
                    $this->db->where('login', $this->session->userdata('ULID'));
                    $this->db->where($row['previlegio'],'1');
                    $previ = $this->db->get($this->conf["tab_painel"]["previlegios"]);
                    $menu = true;                    
                }
                if($row['previlegio'] == "all" || $previ->num_rows() == 1){
                    $m_nome[] = $row['nome_menu'];   
                    $m_id[] = $row['menuid'];
                    $m_img[] = $row['img'];   
                    $m_filho[] = $row['filho'];
                    $menu = true;     
                }                
                   
            }
            if($menu){
                $this->smartyview->assign("M_NOME", $m_nome); 
                $this->smartyview->assign("M_ID", $m_id); 
                $this->smartyview->assign("M_IMG", $m_img); 
                $this->smartyview->assign("M_FILHO", $m_filho);                
            }
        }                
 
    }
     
    // Metodoo index
     function index()
     {
        $this->smartyview->assign("template", "meio");
        $this->smartyview->display('home.tpl');
     }

        
}

?>